package com.ysd.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ysd.entity.Memeber;

public interface MemeberRepository extends JpaRepository<Memeber, Integer>, JpaSpecificationExecutor<Memeber> {

	// 利用原生的sql进行修改操作
	@Query(value = "update memeber set card=?2,category=?3,department=?4,grade=?5,name=?6,phone=?7,profession=?8,sex=?9 where id=?1 ", nativeQuery = true)
	@Modifying
	@Transactional
	int updateMemeber(int id, Integer card, Integer category, String department, String grade, String name,
			Integer phone, String profession, String sex);

	// 利用原生的sql进行重置状态
	@Query(value = "update memeber set status=0", nativeQuery = true)
	@Modifying
	@Transactional
	int setMemeber();

	// 批量删除
	@Modifying
	@Transactional
	@Query("delete from Memeber m  where  m.id in (?1) ")
	int deleteMemeberById(List<Integer> ids);
}
